package com.hhp.hhptt.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;

import com.hhp.hhptt.service.IPeopleService;
import com.hhp.hhptt.entity.People;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hhp
 * @since 2024-03-04
 */
@RestController
@RequestMapping("/people")
public class PeopleController {



@Resource
private IPeopleService peopleService;


@PostMapping("/save")
public Boolean save(@RequestBody People people) {
        return peopleService.saveOrUpdate(people);
        }

@DeleteMapping("/delete/{id}")
public Boolean delete(@PathVariable Integer id) {
        return peopleService.removeById(id);
        }
@PostMapping
public Boolean deleteBatch(@RequestBody List<Integer> ids) {
        return peopleService.removeByIds(ids);
        }

@GetMapping("/getAll")
public List<People> findAll() {
        return peopleService.list();
        }
@GetMapping("/{id}")
public People findOne(@PathVariable Integer id) {
        return peopleService.getById(id);
        }

@GetMapping("/page")
public Page<People> findPage(@RequestParam Integer pageNum,
@RequestParam Integer pageSize) {

        QueryWrapper<People> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc("id");
        return peopleService.page(new Page<>(pageNum, pageSize),queryWrapper);
        }
        }

